package com.tjhk.demo.taos.controlller;

import com.tjhk.demo.taos.result.Result;
import com.tjhk.demo.taos.service.LocationService;
import org.hibernate.validator.constraints.Length;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

@RestController()
@RequestMapping("location")
public class LocationController {
    @Autowired
    private LocationService service;

    @GetMapping("page")
    Result get(@RequestParam(value ="page", defaultValue = "1", required = false) Integer page,
               @RequestParam(value ="limit", defaultValue = "10", required = false) Integer limit,
               @RequestParam(value = "plateNo",required = false) @Length(min = 7,max = 7) String plateNo,
               @RequestParam(value = "stTime",required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime stTime,
               @RequestParam(value = "endTime",required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime endTime
                       ){
        return Result.success(service.page(page,limit,plateNo,stTime,endTime));
    }

}
